package com.ljx.recruitment.oss.factory;

import cn.hutool.extra.spring.SpringUtil;
import com.ljx.recruitment.common.exception.ApiException;
import com.ljx.recruitment.oss.enums.OssEnum;
import com.ljx.recruitment.oss.service.OssStrategy;
import com.ljx.recruitment.oss.service.strategy.ALiYunStrategy;
import com.ljx.recruitment.oss.service.strategy.MinioStrategy;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @Author: LiJunXi
 * @Description:
 * @Date: 2024-11-12  17:54
 */
@Component
public class OssFactory {
    
    @Value("${oss.type}")
    private Integer type;

    public OssStrategy getOssStrategy(){
        if (OssEnum.MINIO.getKey().equals(type)){
            return SpringUtil.getBean(MinioStrategy.class);
        } else if (OssEnum.ALIYUN.getKey().equals(type)){
            return SpringUtil.getBean(ALiYunStrategy.class);
        } else {
            throw new ApiException("存储类型不存在");
        }

    }

    public Integer getOssType(){
        return type;
    }
    


}
